import React, { Component } from 'react'

export default class Demo extends Component {
    
    render() {
        return (
            <div>
                <h2>我是父组件</h2>
                <A render={(name)=><B name={name}/>}/>
            </div>
        )
    }
}
class A extends Component {
    state={name:'tom'}
    render() {
        const {name}=this.state
        return (
            <div>
                <h2>我是A组件</h2>
                {this.props.render(name)}
            </div>
        )
    }
}
class B extends Component {

    render() {
        
        return (
            <div>
                <h2>我是B组件</h2>
            </div>
        )
    }
}